package com.zxkj.commonpatrol.adapt;

import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.google.android.material.checkbox.MaterialCheckBox;
import com.zxkj.commonpatrol.R;
import com.zxkj.commonpatrol.model.entity.AnwerBean;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class AnwerAdapt extends BaseQuickAdapter<AnwerBean, BaseViewHolder> {
    public AnwerAdapt(int layoutResId, @Nullable List<AnwerBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder helper, @Nullable AnwerBean anwerBean) {

        MaterialCheckBox b =helper.itemView.findViewById(R.id.cv1);
        TextView tv =helper.itemView.findViewById(R.id.tv_anwer);
        tv.setText(anwerBean.getTitle());
        if (anwerBean.isChecked()){
            b.setChecked(true);
        }else{
            b.setChecked(false);
        }
        b.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    anwerBean.setChecked(true);
                }else{
                    anwerBean.setChecked(false);
                }
            }
        });


    }



}
